package org.akomantoso.core.data;

import java.io.IOException;

import org.akomantoso.core.data.group.ANsemanticInline;
import org.akomantoso.core.io.Input;
import org.akomantoso.core.io.Output;
import org.akomantoso.core.io.OutputUtil;
import org.akomantoso.core.visitor.AKVisitor;

/**
 * The element quantity is an inline element to identify a text fragment introducing or referring to a quantity. This
 * could be a dimensionless number, or a number referring to a length, weight, duration, etc. or even a sum of money.
 * The attribute normalized contains the value normalized in a number, if appropriate.
 * 
 * <pre>
 *  <xsd:element name="quantity">
 * 		<xsd:complexType mixed="true">
 * 			<xsd:complexContent>
 * 				<xsd:extension base="inlinereqreq">
 * 					<xsd:attribute name="normalized" type="xsd:string"/>
 * 				</xsd:extension>
 * 			</xsd:complexContent>
 * 		</xsd:complexType>
 * 	</xsd:element>
 * </pre>
 * 
 */
public final class Quantity extends InlineReqReqType implements ANsemanticInline {

	public static final String ELEMENT = "quantity";

	public static final String ATTRIBUTE_NORMALIZED = "normalized";
	
	private String _normalized;
	
	public String getNormalized() {
		return _normalized;
	}

	public void setNormalized(String normalized) {
		_normalized = normalized;
	}

	/**
	 * @see org.akomantoso.core.data.InlineReqReqType#writeExternal(org.akomantoso.core.io.Output)
	 */
	@Override
	public <E extends Output> void writeExternal(E out) throws IOException {
		out.writeStart(ELEMENT);
		OutputUtil.writeAttribute(out, ATTRIBUTE_NORMALIZED, _normalized);
		super.writeExternal(out);
		out.writeEnd();
	}

	
	/**
	 * @see org.akomantoso.core.data.InlineReqReqType#readExternal(org.akomantoso.core.io.Input)
	 */
	@Override
	public <E extends Input> void readExternal(E in) throws IOException {
		_normalized = in.readAttribute(ATTRIBUTE_NORMALIZED);
		super.readExternal(in);
	}

	/**
	 * @see org.akomantoso.core.visitor.AKVisitable#accept(org.akomantoso.core.visitor.AKVisitor)
	 */
	@Override
	public void accept(AKVisitor visitor) {
	}

}